<!--{template /module/admin/view/head}-->
<div id="left_layout">
	<div id="main_content" class="container-fluid">
		<!--{template /module/admin/view/head_nav}-->
		<div class="row-fluid">
			<div class="well widget">
				<div class="widget-header">
					<h3 class="title">{lang album.index.view.header}</h3>
				</div>
				<div class="widget-content">
					<div class="action-wrapper">
						<div class="pull-left">
							<a href="javascript:void(null);" id="btn_delete_list" class="btn btn-small" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
							<a href="{$ADMIN_SCRIPT}/album/_pub" class="btn btn-small" {$dispatches[operations][add]}>{lang album.index.view.operation.add}</a>
						</div>
					</div>
					
					<hr>
					<form id="frm_grid" name="frmGrid" action="{$ADMIN_SCRIPT}/album&page={$_var[page]}&psize={$_var[psize]}" method="post">
					<table class="table table-hover">
						<thead>
							<tr>
								<th width="20"><input type="checkbox" class="fancy" name="cbxAll"/></th>
								<th width="90">{lang album.index.view.th.pic}</th>
					            <th width="120">{lang album.index.view.th.identity}</th>
					            <th>{lang album.index.view.th.name}</th>
					            <th width="70">{lang album.index.view.th.size}</th>
					            <th width="85">{lang album.index.view.th.photos}</th>
					            <th width="85">{lang album.index.view.th.username}</th>
					            <th width="130">{lang album.index.view.th.edittime}</th>
					            <th width="90">{lang album.index.view.th.operate}</th>
							</tr>
						</thead>
						<tbody>
							<!--{loop $albums $_loop $album}-->
							<tr class="item-row">
								<td>
						        	<input type="checkbox" class="fancy" name="cbxItem[]" title="{$album[TITLE]}" value="{$album[ALBUMID]}"/>
		           				</td>
							    <td>
							    	<a href="{$ADMIN_SCRIPT}/album/_view&id={$album[ALBUMID]}&page={$_var[page]}&psize={$_var[psize]}">
								    	<!--{if is_array($album['FILE01'])}-->
								    	<img src="{$album[FILE01][0]}" data="{$album[FILE01][4]}" style="width:80px; border:1px solid #ccc;" />
								    	<!--{else}-->
								    	<img src="static/images/no-picture.jpg" width="80" style="width:80px;" />
								    	<!--{/if}-->
								    </a>
							    </td>
					            <td>{$album[IDENTITY]}</td>
					            <td>
					            	<p class="text-success f14">
						            	<a href="{$ADMIN_SCRIPT}/album/_view&id={$album[ALBUMID]}&page={$_var[page]}&psize={$_var[psize]}" title="{$album[TITLE]}">
						            	{$album[TITLE]}
						            	</a>
					            	</p>
									<p class="remark thin">{$album[REMARK]}</p>
					            </td>
					            <td>{$album[SIZE]}</td>
					            <td>{$album[PHOTOS]}个</td>
					            <td class="f12">{$album[USERNAME]}</td>
					            <td class="f12">{$album[EDITTIME]}</td>
					            <td>
					            	<a class="btn btn-mini btn-primary" href="{$ADMIN_SCRIPT}/album/_update&id={$album[ALBUMID]}&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}" {$dispatches[operations][edit]}>{lang admin.operation.edit}</a>
					                <a class="btn btn-mini btn-delete" title="{$album[TITLE]}" data="{$album[ALBUMID]}" href="javascript:void(null);" {$dispatches[operations][delete]}>{lang admin.operation.delete}</a>
				            	</td>
							</tr>
							<!--{/loop}-->
							<!--{if count($albums) == 0}-->
							<tr>
					            <td colspan="9">
					                * {lang admin.operation.empty}
					            </td>
					        </tr>
					        <!--{/if}-->
						</tbody>
					</table>
					</form>
					
					<hr/>
					{$pager}
				</div>
			</div>
		</div>
	</div>
</div>

<script>

$(function(){
	$('.fancy').uniform();
	
	$('#btn_delete_list').click(function(){
		if($("#frm_grid input[name='cbxItem[]']:checked").length > 0){
			var tempHTML = '<p>';
			$("#frm_grid input[name='cbxItem[]']:checked").each(function(){
				tempHTML += $(this).attr('title') + '； ';
			});
			
			tempHTML += '</p>';
			
			$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang album.index.view.operation.delete.message}</p>' + tempHTML, callback:function(){
				$('#modal_dialog .btn-primary').click(function(){
					$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/album&do=delete_list&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}');
					$('#frm_grid').submit();
				});
			}});
		}else $.dialog({message:'{lang album.index.view.operation.empty}'});
	});
	
	$("#frm_grid input[name='cbxAll']").click(function(){
		if(this.checked){
			$('#frm_grid .item-row').addClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', true).parent().addClass('checked');
		}else{
			$('#frm_grid .item-row').removeClass('warning');
			$("#frm_grid input[name='cbxItem[]']").attr('checked', false).parent().removeAttr('class');
		}
	});
	
	$("#frm_grid input[name='cbxItem[]']").click(function(){
		if(this.checked) $(this).parent().parent().parent().parent().addClass('warning');
		else $(this).parent().parent().parent().parent().removeClass('warning');
	});
	
	$('#frm_grid .btn-delete').click(function(){
		var albumid = $(this).attr('data');
		var tempHTML = '<p>' + $(this).attr('title') +  '； </p>';
		$.dialog({submit:'{lang admin.operation.delete}', message:'<p>{lang album.index.view.operation.delete.one}</p>' + tempHTML, callback:function(){
			$('#modal_dialog .btn-primary').click(function(){
				$('#frm_grid').attr('action', '{$ADMIN_SCRIPT}/album&do=delete&id=' + albumid + '&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}');
				$('#frm_grid').submit();
			});
		}});
	});
});
</script>
<!--{template /module/admin/view/foot}-->